# -*- coding:utf-8 -*- 
__date__ = '2021/12/25 11:06 上午'

from util.list_util import random_list


def selection_sort(collection):
    length = len(collection)
    for i in range(length - 1):
        # 获得最小元素的下标，和起始位置的元素比较大小，互换位置
        minIndex = collection.index(min(collection[i:]))
        if i < minIndex:
            collection[i], collection[minIndex] = collection[minIndex], collection[i]
        print(collection)
    return collection


if __name__ == '__main__':
    # random_list = random_list()
    random_list = [-96, 90, 79, 69, 62, -94, -92, -4, 49, -55]
    print("random_list: ", random_list)
    res = selection_sort(random_list)
    print(res == sorted(random_list))
